% NOIP2006-J T3 % input int: s; int: t; int: w; array[1..w] of string: str; % Input consists of 2 lines. The first line contains 3 positive integers separated by a space: s, t, w, where s is the minimum letter's index used, t is the maximum letter's index used, and w is the number of digits (these three values satisfy: 1≤s r[pointer] \/ (l[pointer] = r[pointer] /\ larger(l, r, pointer + 1)) endif; array[1..w] of int: str_int = [get_num(str[i]) | i in 1..w]; array[0..5,1..w] of var s..t: str_list; % In Jam numbers, each letter is unique. constraint str_list[0,1..w] = str_int; constraint forall(i in 1..5)(forall(j,k in 1..w where j!=k)(str_list[i,j]!=str_list[i,k])); constraint not exists(i,j in 1..5 where i!=j)(forall(k in 1..w)(str_list[i,k]=str_list[j,k])); constraint forall(i in 1..5)(forall(j in 1..w-1)(str_list[i,j]